package CamEndzyx;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;

public class ImagePanel extends JPanel {

    public ArrayList<BufferedImage> imglist = new ArrayList<>();

    public MyShape[] shapeArr = new MyShape[100];
    public static int width;
    public static int height;

    public void paint(Graphics gr) {
        super.paint(gr);
        System.out.println ("绘制" + getWidth () + " " + getHeight ());
        if(imglist.size () > 0){
            BufferedImage buffimg = imglist.get (imglist.size () - 1);
            BufferedImage newBuffimg = new BufferedImage (width,height,BufferedImage.TYPE_INT_ARGB);
            Graphics bg = newBuffimg.getGraphics ();
            bg.drawImage (buffimg,0,0,width,height,null);
            gr.drawImage (newBuffimg,0,0,null);
        }

        System.out.println("绘制组件！");
        for(int i = 0; i < shapeArr.length; i++) {
            if (shapeArr[i] == null) break;
            MyShape shape = shapeArr[i];
            shape.drawShape(gr);
        }
    }
}
